package com.epay.epay.api.controller;


import com.epay.epay.model.PayResult;
import com.epay.epay.service.IPayService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

@RestController
@RequestMapping("/api/pay")
@CrossOrigin(originPatterns = "*", allowedHeaders = "*")
public class PayController {

    @Autowired
    IPayService payService;



    @RequestMapping("/")
    public PayResult pay(@RequestParam(required = false,defaultValue = "0.01") BigDecimal money, HttpServletRequest request) {
        return payService.pay(money,request);
    }


    @RequestMapping("/notify")
    public String pay(@RequestParam Map<String,String> body) {
        System.out.println(body);
        return "success";
    }

}
